Crate c2_chacha[][src]

Expand description

Pure Rust ChaCha with SIMD optimizations.

Stream-cipher usage:

#[cfg(features = "std")]
fn demo() {
extern crate c2_chacha;

use c2_chacha::stream_cipher::{NewStreamCipher, SyncStreamCipher, SyncStreamCipherSeek};
use c2_chacha::{ChaCha20, ChaCha12};

let key = b"very secret key-the most secret.";
let iv = b"my nonce";
let plaintext = b"The quick brown fox jumps over the lazy dog.";

let mut buffer = plaintext.to_vec();
// create cipher instance
let mut cipher = ChaCha20::new_var(key, iv).unwrap();
// apply keystream (encrypt)
cipher.apply_keystream(&mut buffer);
// and decrypt it back
cipher.seek(0);
cipher.apply_keystream(&mut buffer);
// stream ciphers can be used with streaming messages
let mut cipher = ChaCha12::new_var(key, iv).unwrap();
for chunk in buffer.chunks_mut(3) {
    cipher.apply_keystream(chunk);
}
}

Modules

Traits which define functionality of stream ciphers.

Type Definitions

Similar to ChaCha20, but with fewer rounds for higher performance.

Similar to ChaCha20, but with fewer rounds for higher performance.

ChaCha20, as used in several standards; from Bernstein’s original publication.

IETF RFC 7539 ChaCha. Unsuitable for messages longer than 256 GiB.

Constructed analogously to XChaCha20, but with fewer rounds for higher performance; mixes during initialization to support both a long nonce and a full-length (64-bit) block counter.

Constructed analogously to XChaCha20, but with fewer rounds for higher performance; mixes during initialization to support both a long nonce and a full-length (64-bit) block counter.

Constructed analogously to XSalsa20; mixes during initialization to support both a long nonce and a full-length (64-bit) block counter.